/*
    Copyright 2020 Udit Karode <udit.karode@gmail.com>

    This file is part of AbleMusicPlayer.

    AbleMusicPlayer is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, version 3 of the License.

    AbleMusicPlayer is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with AbleMusicPlayer.  If not, see <https://www.gnu.org/licenses/>.
*/

package com.salton123.soulove.biz_main.main

import android.Manifest
import android.os.Bundle
import android.widget.Button
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.salton123.feature.ImmersionFeature
import com.salton123.soulove.app.R
import com.salton123.soulove.common.Constants
import io.github.dreierf.materialintroscreen.MaterialIntroActivity
import io.github.dreierf.materialintroscreen.SlideFragmentBuilder

/**
 * The welcome screen that shows up when the required permissions haven't been granted.
 */
@Route(path = Constants.Router.App.WELCOME)
class WelcomeActivity : MaterialIntroActivity() {
    var immersionFeature: ImmersionFeature? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        immersionFeature = ImmersionFeature()
        immersionFeature?.with(this)
        immersionFeature?.onBind()
        immersionFeature?.dardFont()
        super.onCreate(savedInstanceState)
        addSlide(
            SlideFragmentBuilder()
                .backgroundColor(R.color.white)
                .buttonsColor(R.color.black50)
                .image(R.drawable.bg_tired)
                .title(getString(R.string.slide_tips_title))
                .description(getString(R.string.slide_tips_description))
                .build()
        )
        addSlide(
            SlideFragmentBuilder()
                .backgroundColor(R.color.white)
                .buttonsColor(R.color.black50)
                .neededPermissions(
                    arrayOf(
                        Manifest.permission.READ_EXTERNAL_STORAGE,
                        Manifest.permission.WRITE_EXTERNAL_STORAGE
                    )
                )
                .image(R.drawable.bg_manworks)
                .title(getString(R.string.slide_tips_title_one))
                .description(getString(R.string.slide_tips_description_one))
                .build()
        )

        val messageButton = findViewById<Button>(R.id.button_message)
        messageButton.setTextColor(resources.getColor(R.color.black40))
    }

    override fun onFinish() {
        super.onFinish()
        var path = Constants.Router.App.MAIN
        ARouter.getInstance()
            .build(path)
            .navigation(this)
    }

    override fun onDestroy() {
        super.onDestroy()
        immersionFeature?.onUnBind()
    }
}